/*
 * @Author       : Hejh(3010733382@qq.com)
 * @Version      : V1.0
 * @Date         : 2024-01-29 12:45:09
 * @Description  : 用户相关类型
 */

import type { PageRes,  IndexObj } from './commom'

// 用户个人信息
export interface UserProfile {
  id: string
  email: string
  username: string
  nickname: string
  avator: string
  sizeMax: string
  sizeUse: string
  rootSourceId: string
  role: {
    id: string
    name: string
    label: string
    Permissions: IndexObj[]
  }
}

// 用户注册
export interface UserRegister {
  username: string
  password: string
  phone?: string
  email: string
  code: string
}

// 用户登录
export interface UserLogin {
  username: string
  password: string
}

// 验证用户信息合法性
export interface UserValidate {
  username?: string
  phone?: string
  email?: string
}

// 用户修改个人信息
export interface UserProfileReq {
  nickname?: string
  avator?: string
  avatorName?: string
  phone?: string
  email?: string
  password?: string
  oldPassword?: string
  code?: string
  type: 'nickname' | 'avator' | 'phone' | 'email' | 'password'
}

export type UserProfileType = 'nickname' | 'avator' | 'phone' | 'email'

// 用户修改密码接口
export interface PwdUpdate {
  oldPassword: string
  password: string
}

// 给用户发送验证码接口
export interface SendEmailReq {
  methodType: string
  businessType: string
  email: string
  picCode?: string
}

// 用户密码找回接口请求类型
export interface FindPwdReq {
  email: string
  code: string
  password: string
}

// 管理员方

// 启/禁用用户
export interface SetStatusUser {
  userIds: string[]
  status: number
}

// 批量设置用户角色
export interface SetUserRoleReq {
  userIds: string[]
  roleId: string
}

// 批量设置用户个人空间大小
export interface SetUserSizeMaxReq {
  userIds: string[]
  sizeMax: string
}

export interface TokenInfo {
  token: string
  reflesh_token: string
}

// 查询所有不属于任何部门
export interface UserNotDepReq {
  page?: number
  pageSize?: number
}

export interface UserNotDepRes {
  id: string
  username: string
  avator: string
  roleId: string
  sex: number
  email: string
  phone: string
  nickname: string
  isActive: number
  createTime:string
}

export interface UserReq {
  page?: number
  pageSize?: number
  username?: string
  depId?: string
}

export type UserNotDepPageRes = PageRes<UserNotDepRes>

export interface UserCreateReq {
  username: string
  nickname: string
  password: string
  sex?: number
  phone?: string
  email?: string
  roleId: string
  avator?:string
}

export interface UserUpdateReq extends UserCreateReq {
  userId?: string
}

// 用户配置返回
export interface UserOptionsRes {
  showHideFile: string
  showPicThumbnail: string
  repeatFile: string
  theme: string
  renameFormat: string
}

// 更新用户配置
export interface UserOptionReq {
  key: string
  value: string
}

// =============================== 用户页面渲染所需要类型============================================
export interface UserSpaceRowData {
  id: string
  avator: string
  username: string
  sizeUse: string
  lastLogin: string
  createTime: string
}
